package com.example.mobile2021606170hsy0406homework;

import android.os.Bundle;
import android.os.strictmode.WebViewMethodCalledOnWrongThreadViolation;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Main7Activity extends AppCompatActivity {

    private TextView tvMainTitle;
    private TextView tvMainEvaluate;
    private TextView tvMainAskfor;
    private TextView tvMainGrade;
    private EditText edtTxtMainGrade;
    private Button btMainEvaluate;
    private EditText edtTxtMainResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main7);
        initView();
    }

    private void initView() {
        tvMainTitle = findViewById(R.id.tv_main_title);
        tvMainEvaluate = findViewById(R.id.tv_main_evaluate);
        tvMainAskfor = findViewById(R.id.tv_main_askfor);
        tvMainGrade = findViewById(R.id.tv_main_grade);
        edtTxtMainGrade = findViewById(R.id.edtTxt_main_grade);
        btMainEvaluate = findViewById(R.id.bt_main_evaluate);
        edtTxtMainResult = findViewById(R.id.edtTxt_main_result);
    }
    public  void  pingdingonClik(View view){
        String a=edtTxtMainGrade.getText().toString();
        if ((a.length()==0)) {
            Toast.makeText(Main7Activity.this, "请输入分数", Toast.LENGTH_SHORT).show();
        }else {
            double b=Double.parseDouble(a);
            if (b>=90) {
                edtTxtMainResult.setText("A");
            }else  if(80 <=b&&b<=89){
                edtTxtMainResult.setText("B");
            }else  if(70 <=b&&b<=70){
                edtTxtMainResult.setText("C");
            }else  if(60 <=b&&b<=69){
                edtTxtMainResult.setText("D");
            }else  if(b<60){
                edtTxtMainResult.setText("E");
            }
        }
    }
}
